<template>
  <van-uploader :after-read="uploadImg">
    <slot></slot>
  </van-uploader>
</template>
<script>
export default {
    props:{
        userId:{
            type:String,
            default:function(){
                return ""
            }
        }

    },
  methods: {
    uploadImg(e) {
      //   alert(e);
      console.log(e);
      let fromData = new FormData();
      fromData.append("file", e.file);
      fromData.append("fileName", e.file.name);
      // fromData.append('userId',this.userId)
      this.$files(this.$api.upload,fromData).then(
        data => {
          this.$emit("upload-img", this.$api.photoUrl+data.data.address);
        }
      );
    }
  }
};
</script>